package com.tjec.project.mobile.controller;

import com.tjec.framework.security.service.TokenService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.framework.web.domain.TreeSelectNew;
import com.tjec.framework.web.domain.TreeSelectProjectDoc;
import com.tjec.framework.web.page.TableDataInfo;
import com.tjec.project.businessWorkbench.domain.BmsBusinessPickup;
import com.tjec.project.businessWorkbench.domain.BmsProjectDoc;
import com.tjec.project.businessWorkbench.domain.BmsProjectDocCatalog;
import com.tjec.project.businessWorkbench.service.IBmsProjectDocService;
import com.tjec.project.mobile.service.MobileService;
import com.tjec.project.workflow.domain.BmsWorkflow;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 移动端业务主页controller类
 *
 * @author ：cjj
 * @date ：Created in 2020/8/19 18:58
 */
@Api(value = "移动端业务主页接口" , tags = {"移动端业务主页接口"})
@RestController
@RequestMapping("/mobile/business")
public class BusinessWorkbenchController extends BaseController{

    @Autowired
    private MobileService mobileService;

    @Autowired
    private IBmsProjectDocService bmsProjectDocService;

    /**
     * 获取业务概况详细信息
     */
    @ApiOperation("业务概况详细信息")
    @GetMapping(value = "/{businessId}")
    public AjaxResult getInfo(@PathVariable("businessId") String businessId)
    {
        return AjaxResult.success(mobileService.getBusinessSketchMobile(businessId));
    }

    /**
     * 查询收资管理列表
     */
    @ApiOperation("查询收资管理列表")
    @GetMapping("/pickupList")
    public TableDataInfo pickup(BmsBusinessPickup bmsBusinessPickup) {
        startPage();
        List<BmsBusinessPickup> list = mobileService.selectBmsBusinessPickupMobileList(bmsBusinessPickup);
        return getDataTable(list);
    }

    /**
     * 获取项目文档目录下拉树列表
     */
    @ApiOperation("项目文档目录下拉树列表")
    @GetMapping("/projectDocTree")
    public AjaxResult projectDocTree(BmsProjectDoc bmsProjectDoc) {
//        List<TreeSelectNew> trees = mobileService.buildDocCatalogTreeSelectMobile(bmsProjectDocCatalog);
        Map<String,Object> trees = mobileService.lazyBuildDocCatalogTreeSelectMobile(bmsProjectDoc);
        return AjaxResult.success(trees);
    }

    /**
     * 查询项目文档详情
     */
   /* @ApiOperation("查询项目文档详情")
    @GetMapping("/projectDocList")
    public TableDataInfo list(BmsProjectDoc bmsProjectDoc)
    {
        bmsProjectDocService.selectBmsProjectDocList(bmsProjectDoc);
        startPage();
        List<BmsProjectDoc> list = mobileService.selectAllProjectDocQueryMobileList(bmsProjectDoc);
        return getDataTable(list);
    }*/

    /**
     * 查询成果校审列表
     */
    @ApiOperation("成果校审查询")
    @GetMapping("/resultsReviewList")
    public TableDataInfo list(BmsWorkflow bmsWorkflow)
    {
        startPage();
        List<BmsWorkflow> list = mobileService.selectBmsWorkflowMobileList(bmsWorkflow);
        return getDataTable(list);
    }
}
